<?php

namespace App\Http\Controllers\admin;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use DB;

class BigPicController extends Controller
{
    //index
    public function index()
    {
    	return view('admin.bigpic.index');
    }

    public function addfirst(Request $request)
    {
    	
    	$data = $request -> except('_token');        
        if($request -> hasFile('img1'))
        {
            if($request -> file('img1') -> isValid())
            {
                //移动文件
                $suffix = $request -> file('img1') -> getClientOriginalExtension();
                //随机一个文件名
                $filename = 'd1';

                //移动文件
                $request -> file('img1') -> move('./hom/index/imgs', $filename.'.'.$suffix);
                $data['img1'] = $filename.'.'.$suffix;
                
                if($data['img1'])
		        {
		            return redirect('/admin/bigpic') -> with(['info' => '添加成功']);
		        }else
		        {
		            return redirect('/admin/bigpic') -> with(['info' => '添加失败']);
		        }
            }

        }
         return redirect('/admin/bigpic') -> with(['info' => '没有选择图片']);
       
    }

    public function addsecond(Request $request)
    {
    	
    	$data = $request -> except('_token');        
        if($request -> hasFile('img2'))
        {
            if($request -> file('img2') -> isValid())
            {
                //移动文件
                $suffix = $request -> file('img2') -> getClientOriginalExtension();
                //随机一个文件名
                $filename = 'd2';

                //移动文件
                $request -> file('img2') -> move('./hom/index/imgs', $filename.'.'.$suffix);
                $data['img2'] = $filename.'.'.$suffix;
                
                if($data['img2'])
		        {
		            return redirect('/admin/bigpic') -> with(['info' => '添加成功']);
		        }else
		        {
		            return back() -> with(['info' => '添加失败']);
		        }
            }

        }
         return redirect('/admin/bigpic') -> with(['info' => '没有选择图片']);
       
    }

    public function addthird(Request $request)
    {
    	
    	$data = $request -> except('_token');        
        if($request -> hasFile('img3'))
        {
            if($request -> file('img3') -> isValid())
            {
                //移动文件
                $suffix = $request -> file('img3') -> getClientOriginalExtension();
                //随机一个文件名
                $filename = 'd3';

                //移动文件
                $request -> file('img3') -> move('./hom/index/imgs', $filename.'.'.$suffix);
                $data['img3'] = $filename.'.'.$suffix;
                
                if($data['img3'])
		        {
		            return redirect('/admin/bigpic') -> with(['info' => '添加成功']);
		        }else
		        {
		            return back() -> with(['info' => '添加失败']);
		        }
            }

        }
         return redirect('/admin/bigpic') -> with(['info' => '没有选择图片']);
       
    }

    public function addfourth(Request $request)
    {
    	
    	$data = $request -> except('_token');        
        if($request -> hasFile('img4'))
        {
            if($request -> file('img4') -> isValid())
            {
                //移动文件
                $suffix = $request -> file('img4') -> getClientOriginalExtension();
                //随机一个文件名
                $filename = 'd4';

                //移动文件
                $request -> file('img4') -> move('./hom/index/imgs', $filename.'.'.$suffix);
                $data['img4'] = $filename.'.'.$suffix;
                
                if($data['img4'])
		        {
		            return redirect('/admin/bigpic') -> with(['info' => '添加成功']);
		        }else
		        {
		            return back() -> with(['info' => '添加失败']);
		        }
            }

        }
        return redirect('/admin/bigpic') -> with(['info' => '没有选择图片']);
    }
}
